package com.tshopping.service.impl;

import com.tshopping.dao.PictureDao;
import com.tshopping.service.PictureService;
import com.tshopping.util.ResponseData;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.ArrayList;

/**
 * @name: PictureServiceImpl
 * @description: 图片业务层类
 * @author: Jackeys
 * @date: 2021-01-24 16:32
 */
@Service(value = "pictureService")
@Transactional
public class PictureServiceImpl implements PictureService {

    @Autowired
    private PictureDao pictureDao;

    @Override
    /**
     * @description 处理用户添加图片
     * @Param: goods
     * @Param: picture
     * @return ResponseData
     * @author Jackeys
     * @date 2021-01-24 16:34
     */
    public ResponseData addPicture(int goods, String picture) {
        ResponseData responseData=ResponseData.ok();
        responseData.putDataValue("flag",pictureDao.insertGoodsPictures(goods,picture));
        return responseData;
    }

    @Override
    /**
     * @description 处理用户删除图片
     * @Param: id
     * @return ResponseData
     * @author Jackeys
     * @date 2021-01-24 16:35
     */
    public ResponseData deletePicture(int id) {
        ResponseData responseData=ResponseData.ok();
        responseData.putDataValue("flag",pictureDao.deletePictureByPictureId(id));
        return responseData;
    }

    @Override
    /**
     * @description 处理用户更新图片
     * @Param: picture
     * @Param: id
     * @return ResponseData
     * @author Jackeys
     * @date 2021-01-24 16:35
     */
    public ResponseData updatePicture(String picture, int id) {
        ResponseData responseData=ResponseData.ok();
        responseData.putDataValue("flag",pictureDao.updatePictureById(picture,id));
        return responseData;
    }

    @Override
    /**
     * @description 处理用户查询图片
     * @Param: goods
     * @return ResponseData
     * @author Jackeys
     * @date 2021-01-24 16:36
     */
    public ResponseData selectPictures(int goods) {
        ResponseData responseData=ResponseData.ok();
        responseData.putDataValue("pictureList",pictureDao.selectPicturesByGoods(goods));
        return responseData;
    }
}
